package com.joysuch.wwyt.workflow.controller;

import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.exception.ApiCoreException;
import com.joysuch.wwyt.workflow.ProcessMapDetailBean;
import com.joysuch.wwyt.workflow.api.service.NewProcessService;
import com.joysuch.wwyt.workflow.bean.*;
import com.joysuch.wwyt.workflow.service.WorkFlowScreenService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Author:  feizhou
 * Date:    2022/9/22 16:59
 */
@RestController
@RequestMapping("workflow-task/screen")
public class WorkFlowScreenController {

    @Autowired
    private WorkFlowScreenService workFlowScreenService;

    @Autowired
    private NewProcessService newProcessService;

    @RequestMapping("/queryAllDisplayWorkFlow")
    @ApiOperation(value = "查询所有显示的流程")
    public ResultBean queryAllDisplayWorkFlow(String code) {
        // 返回所有作业票名称、id、iconUrl ， 旧版本以 old_ 开头 ， 新版本以 new_开头
        List<WorkFlowScreenBean> workFlowScreenBeans = workFlowScreenService.queryScreenDisplayWorkFlow(code);
        return ResultBean.success(workFlowScreenBeans);
    }

    @RequestMapping("/workflow-list")
    @ApiOperation(value = "大屏作业票流程显示列表")
    public ResultBean workFlowList(String processId, String serialNumber, String code, String bizTypeName) {
        List<ProcessMapListBean> data = workFlowScreenService.searchWorkFlowList(processId, serialNumber, code, bizTypeName);
        return ResultBean.success(data);
    }

    @RequestMapping("/workflow-detail")
    @ApiOperation(value = "大屏作业票详情")
    public ResultBean workFlowDetail(String processId) {
        ProcessInstanceMapScreenDetail data = workFlowScreenService.workFlowDetail(processId);
        return ResultBean.success(data);
    }

    @RequestMapping("/test")
    @ApiOperation(value = "作业票详情测试")
    public ResultBean test(String processId) {
        ProcessMapListBean data = newProcessService.getProcDetail(processId,null);
        return ResultBean.success(data);
    }
}
